
%macro empl_incm_disn;

	proc printto new log = "&logdir./empl_incm_disn.txt";
	run;
	
		data working;
			set rlib.empl_incm;
			dneg = master_income < 0;
			d0 = 0 <= master_income < 10000;
			d10 = 10000 <= master_income < 25000;
			d25 = 25000 <= master_income < 50000;
			d50 = 50000 <= master_income < 100000;
			d100 = 100000 <= master_income < 250000;
			d250 = 250000 <= master_income < 1000000;
			d1000 = master_income >= 1000000;
		run;
		
		proc sort data = working;
			by person_id year;
		run;
		proc sort data = rlib.own_w2;
			by person_id year;
		run;
		
		data working;
			merge working(in=a) rlib.own_w2(in=b);
			by person_id year;
			if a & b;
			
			if year = 2020 then capped_wages = min(10000,wgs_firm);
			if year = 2021 then capped_wages = min(30000,wgs_firm);
		run;
		
		/****************************************
		*										*
		*			Evenly weighted				*
		*										*
		****************************************/
		proc means data = working nway noprint;
			class firm_id year;
			output out = rlib.empl_even_wgt(drop=_type_ _freq_)
				mean(dneg d0 d10 d25 d50 d100 d250 d1000) =
					dneg d0 d10 d25 d50 d100 d250 d1000;
		run;
		
		
		/************************************************
		*												*
		*			Weighted by uncapped wages			*
		*												*
		************************************************/
		proc means data = working nway noprint;
			class firm_id year;
			weight wgs_firm;
			output out = rlib.empl_wg_wgt(drop=_type_ _freq_)
				mean(dneg d0 d10 d25 d50 d100 d250 d1000) =
					dneg d0 d10 d25 d50 d100 d250 d1000;
		run;
		
		proc means data = working nway noprint;
			class firm_id year;
			weight capped_wages;
			output out = rlib.empl_capped_wgt(drop=_type_ _freq_)
				mean(dneg d0 d10 d25 d50 d100 d250 d1000) =
					dneg d0 d10 d25 d50 d100 d250 d1000;
		run;

	

	proc printto;
	run;
	
	
%mend;

